import Vue from 'vue'
import Vuex from 'vuex'
// import createPersistedState from 'vuex-persistedstate';

Vue.use(Vuex)

let moduleFn = require.context('./modules', false, /\.js$/);
let modules = moduleFn.keys().reduce((p, c) => {
    let mod = moduleFn(c).default;
    mod = { ...mod, namespaced: true };
    let modName = c.match(/\.\/(\w+)\.js$/)[1];
    p[modName] = mod;
    return p;
}, {});

const store = new Vuex.Store({
  // plugins: [createPersistedState()], // 缓存state
  modules
})

export default store
